<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div>
        <button onclick="doAxiosAjaxGet()">axios.get(...)</button>
        <button onclick="doAxiosAjaxPost()">axios.get(...)</button>
        <button onclick="doAxiosAjaxPostJson()">axios.getE(...)</button>
    </div>
    <div class="result"></div>
    <script src="js/axios.min.js"></script>
    <script>
        function doAxiosAjaxPostJson() {
            let url="http://localhost:1314/doPostJSON";
            let params={"msg":"hello axios"};
            //axios.defaults.headers.post['Content-Type']='application/x-www-form-urlencoded'
            axios.post(url,params).then(function (result) {
                console.log(result);
                document.querySelector(".result").innerHTML=JSON.stringify(result.data);
            }).catch(function (error) {
                console.log(error);
            })
        }
        function doAxiosAjaxPost() {
            let url="http://localhost:1314/doPost";
            let params="msg=hello axios";
            //axios.defaults.headers.post['Content-Type']='application/x-www-form-urlencoded'
            axios.post(url,params).then(function (result) {
                console.log(result);
                document.querySelector(".result").innerHTML=JSON.stringify(result.data);
            }).catch(function (error) {
                console.log(error);
            })
        }
        function doAxiosAjaxGet() {
            //1,url
            let url="http://localhost:1314/doAjax";
            //2,params
            let params={params: {"msg":"hello axios"}}
            //3,send ajax get request
            axios.get(url,params).then(function (result) {
                console.log(result);
                document.querySelector(".result").innerHTML=JSON.stringify(result.data);//原生的js代码
            }).catch(function (error) {
                console.log(error);
            })
        }
    </script>
</body>

</html>